// Script assets have changed for v2.3.0 see
// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information
function PlayerCollision(){
	
	var _collision = false;
	var _entityList = ds_list_create();
	
	//水平贴图
	 if(tilemap_get_at_pixel(collisionMap, x+hSpeed, y))
	 {
		x -= x mod TILE_SET;
		if(sign(hSpeed)==1) x += TILE_SET - 1;
		hSpeed = 0;
		_collision = true;
	}
	//水平实体碰撞
	var _entityCount = instance_position_list(x + hSpeed, y, pEntity, _entityList, false);
	var _snapX;
	while(_entityCount > 0)
	{
		var _entityCheck = _entityList[| 0];  //ds_list_find_value(_entityList,0)
		if(_entityCheck.entityCollision == true)
		{
			if(sign(hSpeed) == -1) _snapX = _entityCheck.bbox_right + 1;
			else  _snapX = _entityCheck.bbox_left - 1;
			x = _snapX;
			hSpeed = 0;
			_collision = true;
			_entityCount = 0;
		}
		ds_list_delete(_entityList, 0);
		_entityCount--;
	}
	
	//水平移动
	x += hSpeed;
	
	//清空列表
	ds_list_clear(_entityList);
	
	//垂直实体碰撞
	var _entityCount = instance_position_list(x , y + vSpeed, pEntity, _entityList, false);
	var _snapY;
	while(_entityCount > 0)
	{
		var _entityCheck = _entityList[| 0];  //ds_list_find_value(_entityList,0)
		if(_entityCheck.entityCollision == true)
		{
			if(sign(vSpeed) == -1) _snapY = _entityCheck.bbox_bottom + 1;
			else  _snapY = _entityCheck.bbox_top - 1;
			y = _snapY;
			vSpeed = 0;
			_collision = true;
			_entityCount = 0;
		}
		ds_list_delete(_entityList, 0);
		_entityCount--;
	}
	
	//垂直贴图
	 if(tilemap_get_at_pixel(collisionMap, x, y+vSpeed))
	 {
		y -= y mod TILE_SET;
		if(sign(vSpeed)==1) y += TILE_SET - 1;
		vSpeed = 0;
		_collision = true;
	}
	
	//垂直移动
	y += vSpeed;
	
	//销毁列表
	ds_list_destroy(_entityList);
	
	
	
	
	
	
	return _collision;
}